

package com.hazelcast.test.jdbc;

import static com.hazelcast.jet.TestedVersions.ORACLE_PROPERTY_NAME;
import static com.hazelcast.jet.TestedVersions.TEST_ORACLE_VERSION;

public class OracleDatabaseProviderFactory {


    private OracleDatabaseProviderFactory() {
    }

    public static TestDatabaseProvider createTestDatabaseProvider() {
        return createTestDatabaseProvider(TEST_ORACLE_VERSION);
    }

    public static boolean isOracleFreeVersion() {
        return TEST_ORACLE_VERSION.contains("gvenzl/oracle-free");
    }

    static TestDatabaseProvider createTestDatabaseProvider(String dockerImageName) {
        if (dockerImageName.startsWith("gvenzl/oracle-xe")) {
            return new OracleXeDatabaseProvider(TEST_ORACLE_VERSION);
        } else
            if (dockerImageName.startsWith("gvenzl/oracle-free")) {
                return new OracleFreeDatabaseProvider(TEST_ORACLE_VERSION);
            } else {
                String msg = "The image name must be 'gvenzl/oracle-xe' or 'gvenzl/oracle-free'. Please provide a valid value for the system property: " + ORACLE_PROPERTY_NAME;
                throw new IllegalArgumentException(msg);
            }
    }
}
